﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;

public partial class Admin_HeThong_PhanQuyen : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            userselect.DataSource = QuanLyDAL.listAll();
            userselect.DataTextField = "Email";
            userselect.DataValueField = "MaQL";
            userselect.DataBind();
            setgroup();
        }
    }
    protected void setgroup()
    {
        StringBuilder sb = new StringBuilder();
        StringBuilder sb1 = new StringBuilder();
        StringBuilder sb2 = new StringBuilder();
        List<ChucNangINFO> group = ChucNangDAL.listParentByID(0);
        int j = 0;
        for (int i = 0; i < group.Count; i++)
        {
            if (group[i].MaChucNang < 0) continue;
            if (j % 2 == 0)
            {
                sb1.Append("<div class='col-xs-12'><div class='panel panel-default'><div class='panel-heading'>");
                sb1.Append("<h4>" + group[i].TenChucNang);
                sb1.Append("<span data-target='#group_" + group[i].MaChucNang + "' data-toggle='collapse' class='glyphicon glyphicon-chevron-down pull-right group_toggle' toggle='dow'></span></h4>");
                sb1.Append("<div class='form-control'><input type='checkbox' key=" + group[i].MaChucNang + " class='chkAll' id='chkAll_" + group[i].MaChucNang + "' />Tất cả</div></div>");
                sb1.Append("<div class='panel-body collapse group-body' id='group_" + group[i].MaChucNang + "'></div>");
                sb1.Append("</div></div>");
            }
            else
            {
                sb2.Append("<div class='col-xs-12'><div class='panel panel-default'><div class='panel-heading'>");
                sb2.Append("<h4>" + group[i].TenChucNang);
                sb2.Append("<span data-target='#group_" + group[i].MaChucNang + "' data-toggle='collapse' class='glyphicon glyphicon-chevron-down pull-right group_toggle' toggle='dow'></span></h4>");
                sb2.Append("<div class='form-control'><input type='checkbox' key=" + group[i].MaChucNang + " class='chkAll' id='chkAll_" + group[i].MaChucNang + "' />Tất cả</div></div>");
                sb2.Append("<div class='panel-body collapse group-body' id='group_" + group[i].MaChucNang + "'></div>");
                sb2.Append("</div></div>");
            }
            j++;
        }
        sb.Append("<div class='col-xs-12 col-md-6'>" + sb1 + "</div><div class='col-xs-12 col-md-6'>" + sb2 + "</div>");
        ltFnGroup.Text = sb.ToString();
    }
}